
// ====================================

var xml_request_$name$=null;

function extractNode(node, tag,idname, classname, nocc, recurse)
{
	var n;
	var nm=0;
	if (!node) return null;
	alert("for "+tag+"/"+idname+"/"+classname+"/#"+nocc);
	for (n=node.firstChild; n; n=n.nextSibling) {
		if (n.nodeName.toLowerCase() != tag) continue;

		var nid=n.getAttribute("id");
		var ncl=n.getAttribute("class");
		//alert("  got "+n.nodeName+"/"+nid+"/"+ncl+"/#"+nm);

		   
		   if (((idname == "") || (nid.toLowerCase()==idname)) &&
		       ((classname == "") || (ncl.toLowerCase()==classname))) {
				if (nm==nocc) return n;
				nm ++;
		  }
		  if (recurse) {
			//todo
		  }
	}
	return null;
}

// ====================================

var xml_request_$name$=null;

function finishedLoading_$name$(e, request) 
{
	xml_request_$name$ = null;
	showLoadingMessage("parsing $url$");
	if (request.responseXML) {		
		var nll;
		// Get the top level element
		var rootDoc = request.responseXML.documentElement;
		if (!rootDoc) {
			showMessageInContents(contents, getLocalizedString("Invalid URL"),
				getLocalizedString("$url$ does not appear to be a valid URL."));
			return;
		}
		
	} else {
		var doc=document.implementation.createHTMLDocument(request.responseText);
		var nx=doc.getElementsByTagName("html");
		rootDoc=nx.item(0);
		if (!rootDoc) return;
	}
	$parsers$
		
	//var z = document.getElementById("htmlZone");
	//z.innerHTML=node.innerHTML;
	showLoadingMessage("");
}

function load_$name$()
{
	showLoadingMessage("$url$");
	if (xml_request_$name$ != null) {
		xml_request_$name$.abort();
		xml_request_$name$ = null;
	}
	xml_request_$name$ = new XMLHttpRequest();

	xml_request_$name$.onload = function(e) {finishedLoading_$name$(e, xml_request_$name$);}
	//xml_request_$name$.overrideMimeType("text/xml");
	xml_request_$name$.open("GET", "$url$");
	xml_request_$name$.setRequestHeader("Cache-Control", "no-cache");
	xml_request_$name$.send(null);
}


// ====================================


